work around QXmlStreamReader issue on windows.
authortsteven4 <tsteven4@gmail.com>
Sun, 19 Nov 2017 22:09:03 +0000 (15:09 -0700)
committertsteven4 <tsteven4@gmail.com>
Sun, 19 Nov 2017 22:09:03 +0000 (15:09 -0700)
gpx.cc

diff --git a/gpx.cc b/gpx.cc
index a5a390005c28e1837e735e73c341aa60216ae77a..7a4cc63c5127e3ebd480fe36a86a234fa79e76a3 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -1375,6 +1375,22 @@ gpx_read()
       gpx_cdata(reader->text().toString());
       break;
 
+//  On windows with input redirection we can read an Invalid token
+//  after the EndDocument token.  This also will set an error
+//  "Premature end of document." that we will fatal on below.
+//  This occurs with Qt 5.9.2 on windows when the file being
+//  sent to stdin has dos line endings.
+//  This does NOT occur with Qt 5.9.2 on windows when the file being
+//  sent to stdin has unix line endings.
+//  An example of a problematic file is reference/basecamp.gpx,
+//  which fails on windows with this invocation from a command prompt:
+//  .\GPSBabel.exe -i gpx -f - < reference\basecamp.gpx
+//  This was demonstrated on 64 bit windows 10.  Other versions of
+//  windows and Qt likely fail as well.
+//  To avoid this we quit reading when we see the EndDocument.
+//  This does not prevent us from correctly detecting the error
+//  "Extra content at end of document."
+    case QXmlStreamReader::EndDocument:
     case QXmlStreamReader::Invalid:
       atEnd = true;
       break;